package com.example.yyy

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Button
import kotlinx.android.synthetic.main.activity_ui.*
import org.jetbrains.anko.toast
import java.security.acl.Group

class UiActivity : AppCompatActivity(), View.OnClickListener {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_ui)
        initView()
    }

    private fun initView() {
        btn_ui_button.setOnClickListener {
            toast("你点击了${(it as Button).text}")
        }
        btn_ui_button.setOnClickListener(MyClickListener())
        btn_ui_button.setOnClickListener(this)
        //CheckBox,RadioButton,Switch
        //isCheckd勾选isClickable允许点击isEnabled可用isFocusable获得焦点isPressed按下LongClickable允许长按isSelected选择
        cb_ui_checkbox.isChecked=true
        cb_ui_checkbox.setOnCheckedChangeListener { _, isChecked ->
            tv_ui_textView.text ="您 ${ if (isChecked) "勾选" else "取消勾选"}了复选框"
        }
        rgp_ui_rgp.setOnCheckedChangeListener { _, checkedId ->
            tv_ui_textView.text = when(checkedId){
                R.id.rbn_ui_onerbn -> "one"
                R.id.rbn_ui_tworbn -> "two"
                else -> ""
            }
        }
    }
    //内部类
    private inner class MyClickListener : View.OnClickListener{
        override fun onClick(v: View?) {
            TODO("Not yet implemented")
        }

    }
    //接口类
    override fun onClick(v: View?) {
        TODO("Not yet implemented")

    }



}